Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@ethersproject/logger
Advanced tools
@ethersproject/logger is a logging utility designed for use with the ethers.js library. It provides a simple and consistent way to log messages, warnings, and errors, making it easier to debug and track issues in your Ethereum-related applications.
Logging Messages
This feature allows you to log informational messages. The logger instance is created with a context name ('my-app' in this case), which helps in identifying the source of the log messages.
const { Logger } = require('@ethersproject/logger');
const logger = new Logger('my-app');
logger.info('This is an info message');
Logging Warnings
This feature allows you to log warning messages. Warnings are useful for indicating potential issues that are not necessarily errors but should be looked into.
const { Logger } = require('@ethersproject/logger');
const logger = new Logger('my-app');
logger.warn('This is a warning message');
Logging Errors
This feature allows you to log error messages. Errors indicate serious issues that need immediate attention.
const { Logger } = require('@ethersproject/logger');
const logger = new Logger('my-app');
logger.error('This is an error message');
Custom Error Codes
This feature allows you to create and throw custom errors with specific error codes. This is useful for categorizing and handling different types of errors in a more granular way.
const { Logger } = require('@ethersproject/logger');
const logger = new Logger('my-app');
const error = logger.makeError('Custom error message', 'CUSTOM_ERROR_CODE');
logger.throwError('This is a custom error', 'CUSTOM_ERROR_CODE', { additional: 'info' });
Winston is a versatile logging library for Node.js that supports multiple transports (e.g., console, file, HTTP). It is more feature-rich compared to @ethersproject/logger, offering advanced logging capabilities like log levels, custom formats, and more.
Bunyan is another logging library for Node.js that focuses on JSON logging. It provides a simple API for logging and supports features like log levels, serializers, and streams. Bunyan is more suited for applications that require structured logging.
Pino is a fast and low-overhead logging library for Node.js. It is designed for high-performance logging and supports features like log levels, serializers, and transports. Pino is ideal for applications where performance is a critical concern.
This sub-module is part of the ethers project.
It is responsible for managing logging and errors to maintain a standard structure.
For more information, see the documentation.
Most users will prefer to use the umbrella package, but for those with more specific needs, individual components can be imported.
const {
Logger,
// Enums
ErrorCode,
LogLevel,
} = require("@ethersproject/logger");
MIT License.
FAQs
Logger utility functions for ethers.
The npm package @ethersproject/logger receives a total of 691,704 weekly downloads. As such, @ethersproject/logger popularity was classified as popular.
We found that @ethersproject/logger demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.